package com.tess.tboot.dao.mapper;

import com.tess.tboot.base.TbootBaseMapper;
import com.tess.tboot.entity.Role;
import com.tess.tboot.entity.UserRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author duanzonglong
 */
public interface UserRoleMapper extends TbootBaseMapper<UserRole> {

    /**
     * 通过用户id获取
     *
     * @param userId
     * @return
     */
    @Select("select * from t_user_role where user_id=#{userId}")
    List<Role> findByUserId(@Param("userId") String userId);

    /**
     * 通过roleId查找
     * @param roleId
     * @return
     */
    @Select("select * from t_user_role where role_id=#{roleId}")
    List<UserRole> findByRoleId(String roleId);

    /**
     * 删除用户角色
     * @param userId
     */
    @Delete("delete from t_user_role where user_id=#{userId}")
    void deleteByUserId(String userId);
}
